package com.yunhe.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.yun.dao.AdminFenYe;
import com.yun.dao.UserDao;

import com.yun.dao.UserFenYe;
import com.yun.dao.UserSelect;
import com.yunhe.bean.Admin;
import com.yunhe.bean.ShopUser;
import com.yunhe.util.MySession;

public class UserService {
	//检查普通用户
	public boolean checkUser(ShopUser user){
		SqlSession se = new MySession().getSession();
		UserDao  mapper  = se.getMapper(UserDao.class);
		List<ShopUser> list=mapper.checkUser(user);
		boolean b =true;
		if(list.size()>0){
			b=false;
		}else{
			b=true;
		}
		
		return b;
		
	}
	
	//增加普通用户
	public  int submitUser(ShopUser user){
		SqlSession se = new MySession().getSession();
		UserDao mapper = se.getMapper(UserDao.class);
		int a =mapper.addUser(user);
		se.commit();
		return a;
	}
	
	//查询所有的用户
	public List<ShopUser> getCount(){
		SqlSession se =new MySession().getSession();
		UserFenYe mapper =se.getMapper(UserFenYe.class);
		List<ShopUser> count =mapper.getCount();
		return count;
		
	}
	//分页所有的用户
	public List<ShopUser> getFenye(int row){
		SqlSession se =new MySession().getSession();
		UserFenYe mapper =se.getMapper(UserFenYe.class);
		List<ShopUser> user =mapper.getFenYe(row);
		return user;
		
	}
	//搜查用户
	public List<ShopUser> getSelect(ShopUser user){
		SqlSession se =new MySession().getSession();
		UserSelect mapper =se.getMapper(UserSelect.class);
		List<ShopUser> list =mapper.getSelect(user);
		return  list;
		
	}
	


}
